﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Giraffe.Client.Common;
using Giraffe.Core.Common;
using Giraffe.Core.Common.Messengers;
using Giraffe.Core.Model;

namespace Giraffe.Client.ConversationModule.History
{
    public class MessageVM: ViewModelBase
    {
        private readonly IMessage _message;
        private IUser _user;

        public MessageVM(IMessage message)
        {
            _message = message;
            _user = ObjectProvider.Resolve<IUser>();
        }

        public string Sender
        {
            get
            {
                return _message.Sender.Name;
            }
        }

        public string Text
        {
            get
            {
                return _message.Text;
            }
        }

        public DateTime Time
        {
            get
            {
                return _message.Time;
            }
        }

        public bool IsOwnMessage
        {
            get
            {
                MessengerType messengerType = _message.Sender.Messenger;
                return _user.OwnContact.GetMessaengerContact(messengerType) == _message.Sender;
            }
        }
    }
}